package com.dl.DaoImpl;

import com.dl.Bean.Customer;
import com.dl.Dao.LoginYanzheng;
import com.dl.util.DBConnection;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class LoginYanzhengImpl implements LoginYanzheng {
    private Connection conn = null ;
    private Statement st = null ;
    private ResultSet rs=null;
    @Override
    public boolean dengluYanzheng(Customer cs) throws SQLException {
        DBConnection db=new DBConnection();
        conn=db.getConnection();
        st=conn.createStatement();
        String sql="select * from customer";
        rs=st.executeQuery(sql);
        System.out.println("登录验证中");
        while(rs.next()){
            String name=rs.getString("name");
            String password=rs.getString("password");
            System.out.println(name+" "+password);
            if(name.equals(cs.getName())&&password.equals(cs.getPassword())){
                System.out.println("登录验证成功");
                db.AllClose();
                return true;
            }
        }
        System.out.println("登录验证失败");
        db.AllClose();
        return false;
    }
}
